package com.spt.springbootzhsx.controller;

import com.spt.springbootzhsx.entity.Admin;
import com.spt.springbootzhsx.entity.back.AdminBack;
import com.spt.springbootzhsx.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping(value="/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @GetMapping(value="/getAllAdmin")
    public ArrayList<Admin> getAllAdmin(){
        return adminService.getAllAdmin();
    }

    @GetMapping(value="/getAdminAllInfoByAid/{aid}")
    public ArrayList<AdminBack> getAdminAllInfoByAid(@PathVariable("aid") Integer aid) {
         return adminService.getAdminAllInfoByAid(aid);
    }

    @GetMapping(value="/updateAdminPwd/{aid}/{password}")
    public String updateAdminPwd(@PathVariable("aid") Integer aid,@PathVariable("password") String password){
        return adminService.updateAdminPwd(aid,password);
    }
}
